package com.commander.spring.cloud.common;

import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.MethodArgumentNotValidException;

import javax.validation.ConstraintViolationException;
import java.lang.annotation.Documented;
import java.lang.annotation.Inherited;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;
import java.util.NoSuchElementException;

import static java.lang.annotation.ElementType.METHOD;
import static java.lang.annotation.ElementType.TYPE;
import static java.lang.annotation.RetentionPolicy.RUNTIME;
import static org.springframework.transaction.annotation.Isolation.READ_COMMITTED;
import static org.springframework.transaction.annotation.Propagation.REQUIRED;

/**
 * description:
 * 事务注解
 *
 * Date: 2017/12/21
 * Time: 18:42
 *
 * @author zhangxin
 */
@Inherited
@Documented
@Retention(RUNTIME)
@Target({
        METHOD, TYPE })
@Transactional(propagation = REQUIRED, isolation = READ_COMMITTED, readOnly = false,
        rollbackFor = { IllegalArgumentException.class,
                MethodArgumentNotValidException.class, ConstraintViolationException.class,
                NoSuchElementException.class, RuntimeException.class,
                Exception.class, Throwable.class })
public @interface TX {
}
